//[1,4,5,2,0,2]
//9
// 跳房子来咯, 使用双for + map + 剪枝, 应该是最优解了,  待会再看看是否有别的解法
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let total;
let initArr = [];
rl.on("line", (line)=>{
    if(initArr.length === 0) {
        initArr = line.trim().replace('[', "").replace("]", "").split(",").map(Number)
    } else {
        total = Number(line.trim())
       getResult(total, initArr)

        // clear
        total = undefined
        initArr.length = 0
    }

})

function getResult(total, initArr) {
    let obj = {}
    for (const i in initArr) {
        let num = initArr[i]
        if(!obj[num]) {
            obj[num] = []
        }
        obj[num].push(i)
    }
    let ans = []

    // 双for查找
    for (let i = 0; i < initArr.length; i++) {
        let a = initArr[i]
        for (let j =  i + 1; j < initArr.length ; j++) {
            let b = initArr[j]
            let c = total - (a + b)
            if(obj.hasOwnProperty(c)) {
                // 找到了
                for (const index of obj[c]) {
                    if(index > j) {
                        ans.push([i, j, index])
                        break;
                    }
                }

            }
        }
    }

    if(ans.length === 1) {
        let arr = ans[0]
        console.log(`[${initArr[arr[0]]},${initArr[arr[1]]},${initArr[arr[2]]}]`)
    } else {
        let arr = ans.reduce((acc, arr)=>{
            let accCount = acc[0] + acc[1] + acc[2]
            let arrCount = arr[0] + arr[1] + arr[2]
            if(arrCount < accCount) {
                return arr
            }
            return acc

        }, ans[0])
        console.log(`[${initArr[arr[0]]},${initArr[arr[1]]},${initArr[arr[2]]}]`)
    }
}